// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import RadialBlurShader from "./RadialBlurShader";

const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {
    @property(cc.Slider)
    slider: cc.Slider = null;

    @property(RadialBlurShader)
    shader: RadialBlurShader = null;

    protected start(): void {
        this.slider.node.on('slide', this.onSlide, this);
    }

    onSlide() {
        this.shader.blurRadius = cc['math'].clamp(Math.floor(this.slider.progress * 10), 0, 10);
    }
}
